import os.path

from flask import (
    Blueprint, request, session, current_app, send_from_directory, url_for,redirect
)

from .db import get_db
from .auth import login_required

bp = Blueprint('index', __name__, url_prefix='')


@bp.route('/',methods=['GET'])
def root():
    return redirect(url_for('index'))


@bp.route('/index')
def index():
    return send_from_directory(os.path.join(current_app.root_path,'static'),'index.html')


@bp.route('/query', method=['GET', 'POST'])
def query_artwork():
    if request.method == 'POST':
        key_word = request.json['key_word']

